#ifndef DECORATOR_H
#define DECORATOR_H
#include "javabean.h"
#include <iostream>
using namespace std;

class Car{
public:
    virtual void show()=0;
};

class RunCar:public Car{
public:
    void run() {
        cout << "可以跑" << endl;
    }
    void show(){
        run();
    }
};

class SwimCarDirector : public Car {
    PointerPropertyBuilderByName(Car,car,private)
public:
    //这里送入被包装对象是关键
    SwimCarDirector(Car *p){
        this->m_car=p;
    }
    void swim(){
        cout<<"可以游泳"<<endl;
    }

    // Car interface
public:
    void show(){
        //使用他人的功能
        this->m_car->show();
        //调用自己的功能。
        this->swim();
    }
};

class FlyCar:public Car{
    PointerPropertyBuilderByName(Car,car,private)
public:
    FlyCar(Car *p){
        this->m_car=p;
    }
    void fly(){
        cout<<"可以飞"<<endl;
    }

    // Car interface
public:
    void show(){
        this->m_car->show();
        this->fly();
    }
};


#endif // DECORATOR_H
